package com.rhzy.wnhc.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rhzy.wnhc.entity.*;
import com.rhzy.wnhc.service.TAreacodeService;
import com.rhzy.wnhc.service.TJobWishService;
import com.rhzy.wnhc.service.TPersonService;
import com.rhzy.wnhc.util.AjaxResult;
import com.rhzy.wnhc.util.CheckIdcardIsLegal;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wen
 * @since 2020-02-18
 */
@Api(tags = "地址管理")
@RestController
@RequestMapping("/area")
public class AreaController {

    @Autowired
    TAreacodeService areacodeService;

    @ApiOperation(value = "获取子集地址", tags = {"地址管理",})
    @RequestMapping(value = "/getAreaByPre/{areaCode}", method = RequestMethod.GET)
    public AjaxResult getAreaByPre(@PathVariable String areaCode){
        try{

           if(StringUtils.isEmpty(areaCode)){
               areaCode="1";
           }
            List<TAreacode> areacodeList=areacodeService.list(new LambdaQueryWrapper<TAreacode>().eq(TAreacode::getAreaParent,areaCode));
            return AjaxResult.addSuccess(areacodeList);
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.addError("异常："+e.getMessage());
        }

    }


}
